<template>
  <div></div>
</template>
<script>
  import {
    gzhGetToken
  } from '@/api/gzh.js'
  export default {
    data() {
      return {
        code: undefined,
        state: undefined,
        stateSource: {
          shenxiangShop: {
            secretKey: '7d8b131aed88f69706a0851348a68f7e',
            source: '公众号',
          }
        }
      }
    },
    created() {
      this.code = this.$utils.getUrlParam('code');
      this.state = this.$utils.getUrlParam('state');
      //alert(this.code+','+this.state)
      //alert(location.href)
    },
    mounted() {
      this.to();
    },
    methods: {
      // 解析code并跳转
      async to() {
        var res = await gzhGetToken(this.code);
        //alert(JSON.stringify(res.data))
        var query = Object.assign({token:res.data}, this.stateSource[this.state]);
        this.$router.push({
          path: '/temp/index',
          query: query
        });
      }
    }
  }
</script>
